# -*- coding: utf-8 -*-
from scpy.logger import get_logger
import os
import sys
import json
import numpy as np
from collections import Counter
import datetime
reload(sys)
sys.setdefaultencoding('utf-8')

logger = get_logger(__file__)

CURRENT_PATH = os.path.dirname(__file__)
if CURRENT_PATH:
    CURRENT_PATH = CURRENT_PATH + "/"

with open(CURRENT_PATH + 'schoolDict.json','r') as f:
    schoolDict = json.loads(f.read())

def trans_counter_to_key_value(counterData):
    resultList = list()
    totalNum = sum(counterData.values())
    for item in counterData.items():
        if item[0] in ['',' ']:
            continue
        itemDic = {
            'name':"",
            'value':""
        }
        itemDic['name'] = item[0]
        itemDic['value'] = round(float(item[1])/totalNum*100,2)
        resultList.append(itemDic)
    return resultList

def get_school_category(schoolName):
    for schoolItem in schoolDict:
        if schoolName.find(schoolItem.get('schoolname','')) != -1:
            if schoolItem.get('f985')=='1' or schoolItem.get('f211')=='1':
                return '985/211本科院校'
            if schoolItem.get('schooltype')=='普通本科':
                return '普通本科院校'
            if schoolItem.get('schooltype')=='独立院校':
                return '民办本科院校'
            if schoolItem.get('schooltype')=='高职高专':
                return '专科院校'
        else:
            continue
    return '其他院校'

def schoolInfo_addition(infoDict,schoolCategory):
    if schoolCategory in infoDict.keys():
        infoDict[schoolCategory] += 1
    else:
        infoDict[schoolCategory] = 1

if __name__ == '__main__':
    pass